<%--yhb--%>
<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@include file="/commons/include/html_doctype.html" %>
<html>
<head>
<title>选择用户</title>
<c:set var="ctx" value="${pageContext.request.contextPath}"></c:set>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<link type="text/css" rel="stylesheet" href="${ctx}/js/easyui/css/default/layout.css" />
<link type="text/css" rel="stylesheet" href="${ctx}/js/easyui/css/default/panel.css" />
<link type="text/css" rel="stylesheet" href="${ctx}/js/tree/zTreeStyle/zTreeStyle.css" />
<style type="text/css">
#ul_dept,#ul_role,#ul_online{padding-left:0;padding-top:0;}
#div_center{overflow:auto;}
#ifrm_User{width:100%;height:99%;}
html,body{width: 100%;height: 100%;}
#divCate div .tree{margin:0 0 0 0; height: 100%; }
#userListFrame{width: 100%; height:100%;}
#btns{width:98%;height:25px;margin:3px;padding-top:6px;border:solid 0px black;}
</style>
<script type="text/javascript" src="${ctx}/js/jquery/jquery.js"></script>
<script type="text/javascript" src="${ctx}/js/easyui/jquery.easyui.js"></script>
<script type="text/javascript" src="${ctx}/js/tree/jquery-ztree.js"></script>
<script type="text/javascript" src="${ctx }/js/util/util.js"></script>
<script type="text/javascript">
var _deptTree;
var _roleTree;
var _frame="ifrm_User";
var isMulti=window.dialogArguments.isMulti;
$(function(){
	//部门树
	$("#ul_dept,#ul_role,#ul_online").css("height","97%");
	$("#"+_frame).attr("src","${ctx }/manage/sys/user/getUserList.htm?isMulti="+isMulti);
	//加载部门树
	$.post("${ctx}/manage/sys/dept/getDepartment2.htm",function(data){
		_deptTree=loadDept(data);
		
	});
	//加载角色树
	$.post("${ctx}/manage/rbac/role/getSysRoleTree.htm",function(data){
		_roleTree=loadRole(data);
	});
	//加载在线树
	/*
	var _online;
	$.post("",function(data){});*/
	//确定按钮。
	$("#btnOk").click(function(){
		var frame=window.frames["ifrm_User"];
		var aryJson=null;
		try
		{
			var str=frame.getSelectUsers();
			aryJson=eval(str);
		}catch(e)
		{
			return;
		}
		if(aryJson.length==0)
		{
			alert("还没有选择用户，请先选择!");
		}
		else
		{
			window.returnValue=aryJson;
			window.close();
		}
	});
	//取消按钮。
	$("#btnCancel").click(function(){
		window.close();
	});
});
function loadDept(data){
	return $("#ul_dept").zTree({isSimpleData:true,treeNodeKey:"id",treeNodeParentKey:"pid",expandSpeed:"",callback:{click:deptClick}},eval(data));
}
function loadRole(data){
	return $("#ul_role").zTree({isSimpleData:true,treeNodeKey:"id",treeNodeParentKey:"pid",expandSpeed:"",callback:{click:roleClick}},eval(data));
}
function deptClick(){
	attachUrl("${ctx}/manage/sys/user/getUserList.htm?deptid="+_deptTree.getSelectedNode().id+"&cate=1"+"&isMulti="+isMulti,_frame);
}
function roleClick(){
	var _roleid=_roleTree.getSelectedNode().id;
	if(-1!=_roleid.indexOf("role_")){
		_roleid=_roleid.replace("role_","");
	}else{
		return;
	}
	attachUrl("${ctx}/manage/sys/user/getUserList.htm?roleid="+_roleid+"&cate=2"+"&isMulti="+isMulti,_frame);
}
</script>
</head>
	<body>
		<div class="easyui-layout" style="width:100%;height:100%;">
			<div region="north" style="height:50px;background-color:#eef5fd;">
				<div class="query">
					<form action="getSys.htm" method="post" style="float: left;">
						<label for="name">关键字:</label>
						<input type="text" id="name" name="name" class="input" size="50" />
						<input type="button" value="提 交" />
					</form>
				</div>
			</div>
			<div region="west" title="所有分类方式" style="width:230px;height:100%;">
				<div id="divCate" class="easyui-accordion" style="width: 228px; height: 372px;">
					<div title="按部门分类" iconCls="icon-ok">
						<ul id="ul_dept" class="tree" />
					</div>
					<div title="按角色分类" iconCls="icon-ok">
						<ul id="ul_role" class="tree" /> 
					</div>
					<div title="按在线人员分类" iconCls="icon-ok">
						<ul id="ul_online" class="tree" /> 
					</div>
				</div>
			</div>
			<div region="south" style="height:40px;background-color:#eef5fd;" align="center" >
				<div id="btns" align="center">
					<input id="btnOk" type="button" value="确认" class="btnSave" />
					<input id="btnCancel" type="button" value="取消" class="btnSave" />
				</div>
			</div>
			<div id="div_center" region="center" style="width:100%;height:100%;">
				<iframe id="ifrm_User" frameborder="0" />
			</div>
		</div>
	</body>
</html>